home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / drdobbs / 1991 / 01 / c_shell.asc < prev    next >
Text File  |  1990-12-07  |  1KB  |  56 lines

  1. _EXAMINING THE HAMILTON C SHELL_
  2. by Scott Richman
  3.  
  4. [LISTING ONE]
  5.  
  6. # CTL_T.CSH
  7.  
  8. while (1)            # endless
  9.  echo -n ^x14 > com1:        # send control t to com1:
  10.  sleep 400            # Zzz for 400 seconds
  11. end # while
  12.  
  13.  
  14. [LISTING TWO]
  15.  
  16. # Procedure zcw  builds Zortech C++ and creates a PM program,
  17.     proc zcw(name)              # param name
  18.         ztc -W -c $name.cpp        # compile ($name is param name)
  19.         # we test name.obj for eistance, 
  20.         if (-e  $name.obj ) then    # got valid obj file to link
  21.             link $name,/align:16,NUL,os2+d:\oz\cp\srzpm.lib,$name
  22.              rm $name.obj        # remove the obj
  23.         end     # if
  24.     end  # proc
  25.  
  26.     zcw $argv  # now here's the invocation of my proc defined above.
  27.  
  28. [LISTING THREE]
  29.  
  30. proc ged(edt_str,files)              # 2 params
  31. local i                    #local variables used
  32. local n
  33. foreach i ($files)             # loop thru the files
  34.     @ n = concat($i:r,".bak")    # save a backup (:r is root name)
  35.     cp -l  $i:f  $n:f         # copy it (:f is full name)
  36.      sed "$edt_str" < $n:f > $i:f    # edit from new to i
  37. end # foreach i
  38. end # end ged proc()
  39.  
  40. [EXAMPLE 1:  Commands to print the attributes of a specified file.]
  41.  
  42.      if ( -d $a) echo $a is a directory
  43.     if ( -H $a) echo $a is Hidden
  44.     if ( -R $a) echo $a is ReadOnly
  45.     if ( -S $a) echo $a is SystemFile
  46.     if ( -e $a) echo $a exists
  47.     if ( -x $a) echo $a Is Executable
  48.     if ( -z $a) echo $a Zero Length
  49.  
  50. [EXAMPLE 2: Command to find all duplicate file names on the  
  51. current disk]
  52.  
  53. foreach i (`ls -r \`:gt) echo $i; end | sort | uniq -d
  54.  
  55.  
  56.